package oa.web.controller;

import java.util.List;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import oa.biz.ActivityActorBiz;
import oa.biz.ActivityBiz;
import oa.biz.AnnouncementBiz;
import oa.biz.DocumentBiz;
import oa.biz.EmployeeBiz;
import oa.biz.MessageBiz;
import oa.entity.Activity;
import oa.entity.ActivityActor;
import oa.entity.Employee;

@Controller
@RequestMapping("/admin")
public class HomeController {
	@Autowired
	private ActivityBiz actbiz;
	@Autowired
	private ActivityActorBiz actorbiz;
	@Autowired
	private EmployeeBiz empbiz;
	@Autowired
	private MessageBiz messagebiz;
	@Autowired
	private AnnouncementBiz annbiz;
	@Autowired
	private DocumentBiz docBiz;
	@RequestMapping("/index")
	public String index(Model model,HttpSession session){
		Employee emp = (Employee)session.getAttribute("employee");
		int receiverId =emp.getId();
		model.addAttribute("paperlist",annbiz.getAllIndex());
		model.addAttribute("employee",empbiz.getAll());
		model.addAttribute("messageUnread",messagebiz.getUnread(receiverId, 0));
		return "index";
	}

	@RequestMapping("/active-list")
	public String activeList(HttpSession session, Model model){
		Employee emp = (Employee) session.getAttribute("employee");
		List<Employee> employee =  empbiz.getAll();
		int ActorId =emp.getId();
		List<Activity> list=actbiz.getAll(ActorId);
		List<ActivityActor> actorlist = actorbiz.getAll();
		model.addAttribute("activeList",list);
		model.addAttribute("actorlist",actorlist);
		model.addAttribute("emp",employee);
		return "active-list";
	}
	@RequestMapping("/calendar")
	public String calendar(){
		return "calendar";
	}
	@RequestMapping("/message-send")
	public String sendMessage(){
		return "message-send";
	}
}
